package com.wealth.wechat.util;

import java.util.List;
import java.util.Map;

import net.sf.json.JSONObject;

@SuppressWarnings("unchecked")
public class JsonParser {
	
	/** Map转json字符串 */
	public static String map2Json(Map<String, Object> paramMap){
		if(CommonUtil.isNull(paramMap))
			return "";
		return JSONObject.fromObject(paramMap).toString();
	}

	/** List转json字符串 */
	public static String list2Json(List<Object> list){
		if(CommonUtil.isNull(list))
			return "";
		return JSONObject.fromObject(list).toString();
	}
	
	/** json转Map */
	public static Map<String, Object> json2Map(String jsonStr){
		if(CommonUtil.isNull(jsonStr))
			return null;
		JSONObject jsonObj = JSONObject.fromObject(jsonStr);
		Map<String, Object> map = (Map<String, Object>)jsonObj;
		return map;
	}
	
}
